<template>
	<view>
		<view :class="'navbar ' + parameter.class" :style="'height:' + navH + 'rpx'">
			<view class="navbarH" :style="'height:' + navH + 'rpx;'">
				<view class="navbarCon acea-row row-center-wrapper" v-if="parameter.navbar==0">
					<view class="search acea-row row-middle" @tap="setGoodsSearch"><text
							class="iconfont icon-xiazai5"></text>搜索商品</view>
					<view class="logo">
						<image :src="logoUrl"></image>
					</view>
				</view>
				<view class="navbarCon acea-row row-center-wrapper" v-if="parameter.navbar==1">
					<view :class="'name ' + (parameter.color==true?'on':'') + ' line1'">{{parameter.title}}</view>
					<view :class="'iconfont icon-xiangzuo ' + (parameter.color==true?'on':'')"
						v-if="parameter.return==1" @tap="returnFun"></view>
				</view>
			</view>
		</view>
		<view :style="'height:' + navH + 'rpx'"></view>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				navH: ""
			};
		},

		components: {},
		props: {
			parameter: {
				type: Object,
				default: () => {}
			},
			logoUrl: {
				type: String,
				default: ''
			}
		},
		mounted: function() {
			this.setClass();
			var pages = getCurrentPages();
			if (pages.length <= 1)
				this.parameter.return = 0
		},
		beforeMount: function() {

			this.navH = app.globalData.navHeight

		},
		methods: {
			returnFun: function() {
				wx.navigateBack({
					delta: 1
				}); // var pages = getCurrentPages();
				// wx.navigateBack({
				//   delta: pages.length-2
				// });
			},
			setGoodsSearch: function() {
				wx.navigateTo({
					url: '/pages/goods_search/index'
				});
			},
			setClass: function() {
				var color = '';

				switch (this.parameter.class) {
					case "0":
					case 'on':
						color = 'on';
						break;

					case '1':
					case 'black':
						color = 'black';
						break;

					case '2':
					case 'gray':
						color = 'gray';
						break;

					case '3':
					case "red":
						color = 'red';
						break;

					case '4':
					case "gradual01":
						color = 'gradual01';
						break;

					default:
						break;
				}


				this.parameter.class = color

			}
		}
	};
</script>
<style>
	@import "./index.css";
</style>
